package com.zbkj.admin.boot.redisson.topic;

import com.zbkj.admin.boot.redisson.common.RedisNameResolver;
import org.redisson.api.RedissonClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Redisson pub/sub 发布配置
 *
 * @author L.cm
 */
@Configuration
@ConditionalOnBean(RedissonClient.class)
public class RedissonRTopicConfiguration {

    @Bean
    public RTopicEventPublisher topicEventPublisher(RedissonClient client,
                                                                                    RedisNameResolver resolver) {
        return new RedissonTopicEventPublisher(client, resolver);
    }

    @Bean
    public RTopicListenerDetector topicListenerDetector(RedissonClient client,
                                                        RedisNameResolver resolver) {
        return new RTopicListenerDetector(client, resolver);
    }

}
